<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_adds', function (Blueprint $table) {
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade'); // 外键关联
            $table->string('truename', 20)->default('');
            $table->string('oicq', 25)->default('');
            $table->string('msn', 120)->default('');
            $table->string('mycall', 30)->default('');
            $table->string('address')->default('');
            $table->string('zip', 8)->default('');
            $table->smallInteger('spacestyleid')->default(0);
            $table->string('homepage', 200)->default('');
            $table->text('saytext');
            $table->string('company')->default('');
            $table->string('fax', 30)->default('');
            $table->string('avatar')->default(''); // userpic
            $table->string('spacename')->default('');
            $table->text('spacegg');
            $table->integer('viewstats')->default(0);
            $table->unsignedInteger('login_count')->default(0);
            $table->timestamps();

            // 添加外键约束
            $table->primary(['user_id']); // 设置主键
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_adds');
    }
};
